import 'package:get/get.dart';
import 'package:xinxuan/http/http_util_service.dart';
import 'package:xinxuan/vo/common_vo/common_pagination_vo.dart';
import 'package:xinxuan/vo/team_members_vo.dart';

class SpaceStatisticsDetailPageController extends GetxController {

  /// 团队表现
  var teamMembersVo = TeamMembersVo(data: [], meta: TeamMembersMeta(pagination: CommonPagination(total: 0, currentPage: 1))).obs;

  @override
  void onReady() {
    getTeamMembers();
    super.onReady();
  }

  /// 获取团队表现
  getTeamMembers() async {
    teamMembersVo.value.meta!.pagination!.currentPage = 1;
    TeamMembersVo tempVo = await HttpUtilService.getTeamMembers(page: teamMembersVo.value.meta!.pagination!.currentPage!);
    teamMembersVo.value = tempVo;
    update();
  }

  /// 加载更多团队表现
  onloadTeamMembers() async {
    if (teamMembersVo.value.meta!.pagination!.total! <= teamMembersVo.value.data!.length) {
      return;
    }
    teamMembersVo.value.meta!.pagination!.currentPage = teamMembersVo.value.meta!.pagination!.currentPage! + 1;
    TeamMembersVo tempVo = await HttpUtilService.getTeamMembers(page: teamMembersVo.value.meta!.pagination!.currentPage!);
    teamMembersVo.value.data!.addAll(tempVo.data!);
    update();
  }

}